#pragma once

#include "usbproto.h"
#include <rtl/list.h>

VOID AgpPrintEfuseState();
VOID AgpPrintBootInfo();

VOID AgpBootLk(PVOID LkBase, SIZE LkSize, UINTPTR Entry, PVOID AtfBase, SIZE AtfSize);
VOID AgpBootMtkDa(UINTPTR DaStart, SIZE DaSize, UINTPTR LkEntry, BOOLEAN UseLk);
VOID AgpBootPl(UINTPTR Entry);

VOID AgpRetrieveRamConsole(UINT32 Flags);

// lock access to some partitions by default (this can be disabled by using --dangerous flag)
#define AG_P_SECPOL_ALLOW_READ (1)
#define AG_P_SECPOL_ALLOW_WRITE (1 << 1)

typedef struct _AG_PTE
{
    UINT64 FirstLba;
    UINT64 LastLba;
    UINT64 Policy;
    RTL_LIST Node;
    CHAR Name[36];
} AG_PTE, *PAG_PTE;

BOOLEAN AgpReadPartitionTable(INT MmcControllerIndex);
PAG_PTE AgpLookupPartition(INT Mmc, CONST CHAR *Name);

VOID AgpDumpSecpol();
VOID AgpUnlockDevice();
VOID AgpLockDevice();

BOOLEAN AgpRunTest(INT Test);

VOID AgpPatchLk(PVOID Address, PVOID CodeStart, SIZE Size, UINT32 BootMode, UINT32 Flags);